package com.iot.modbus.route.impl;

import com.iot.modbus.manager.ReaderSessionManager;
import com.iot.modbus.route.ReaderSessionRoute;
import com.serotonin.modbus4j.ip.IpParameters;

import java.nio.ByteOrder;

public class SimpleReaderSessionRoute implements ReaderSessionRoute {


    @Override
    public boolean readBoolean16(IpParameters ipParameters, int startOffset, ByteOrder byteOrder, int bit) {
        return ReaderSessionManager.get(ipParameters).readBoolean16(startOffset, byteOrder, bit);
    }

    @Override
    public short[] read(IpParameters ipParameters, int startOffset, int numberOfRegisters) {
        return ReaderSessionManager.get(ipParameters).read(startOffset, numberOfRegisters);
    }

    @Override
    public Short readInt16(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return ReaderSessionManager.get(ipParameters).readInt16(startOffset,byteOrder);
    }

    @Override
    public Integer readUInt16(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return ReaderSessionManager.get(ipParameters).readUInt16(startOffset,byteOrder);
    }

    @Override
    public Integer readInt32(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return ReaderSessionManager.get(ipParameters).readInt32(startOffset,byteOrder);
    }

    @Override
    public Long readUInt32(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return ReaderSessionManager.get(ipParameters).readUInt32(startOffset,byteOrder);
    }

    @Override
    public Long readInt64(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return ReaderSessionManager.get(ipParameters).readInt64(startOffset,byteOrder);
    }

    @Override
    public Float readFloat32(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return ReaderSessionManager.get(ipParameters).readFloat32(startOffset,byteOrder);
    }

    @Override
    public Double readFloat64(IpParameters ipParameters, int startOffset, ByteOrder byteOrder) {
        return ReaderSessionManager.get(ipParameters).readFloat64(startOffset,byteOrder);
    }

}
